package com.yunkaweilai.android.activity.recharge;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yunkaweilai.android.R;
import com.yunkaweilai.android.base.BaseActivity;
import com.yunkaweilai.android.net.Glide.GlideUtils;
import com.yunkaweilai.android.utils.TitleBuilder;
import com.zhy.adapter.abslistview.CommonAdapter;
import com.zhy.adapter.abslistview.ViewHolder;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2019/2/27.
 */

public class RechargePayTypeActivity extends BaseActivity {


    @BindView(R.id.titlebar_iv_left)
    ImageView titlebarIvLeft;
    @BindView(R.id.titlebar_tv_left)
    TextView titlebarTvLeft;
    @BindView(R.id.titlebar_tv)
    TextView titlebarTv;
    @BindView(R.id.titlebar_iv_right_2)
    ImageView titlebarIvRight2;
    @BindView(R.id.titlebar_iv_right)
    ImageView titlebarIvRight;
    @BindView(R.id.titlebar_tv_right)
    TextView titlebarTvRight;
    @BindView(R.id.id_view_underline)
    View idViewUnderline;
    @BindView(R.id.rl_titlebar)
    RelativeLayout rlTitlebar;
    @BindView(R.id.id_listview)
    ListView idListview;
    private ArrayList<String> list = new ArrayList<>();
    private CommonAdapter<String> adapter;
    public static final String IS_PAY_TYPE = "IS_PAY_TYPE";
    public static final String PAY_TYPE_NAME = "PAY_TYPE_NAME";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.recharge_time_layout);
        ButterKnife.bind(this);
        new TitleBuilder(mAc).setTitleText("支付方式")
                .setLeftImage(R.mipmap.ic_go_back)
                .setLeftOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        finish();
                    }
                });
        list.add("支付宝");
        list.add("微信");
        adapter = new CommonAdapter<String>(this, R.layout.item_list_pay_type, list) {
            @Override
            protected void convert(ViewHolder viewHolder, String item, int position) {
                ImageView idImg = viewHolder.getView(R.id.id_img);
                if (position == 0){
                    GlideUtils.loadImage(mAc,R.mipmap.zfb_img,idImg);
                }else{
                    GlideUtils.loadImage(mAc,R.mipmap.wx_img,idImg);
                }
                viewHolder.setText(R.id.id_tv_company, item + "");
            }
        };
        idListview.setAdapter(adapter);
        idListview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent();
                intent.putExtra(PAY_TYPE_NAME,list.get(position)+"");
                if (position == 0){
                    intent.putExtra(IS_PAY_TYPE,true);
                }else{
                    intent.putExtra(IS_PAY_TYPE,false);
                }
                setResult(RESULT_OK,intent);
                finish();
            }
        });
    }
}
